import React, { Component } from 'react';
import {connect} from 'react-redux'

class Home extends Component {

    handleTakeEvery = () => {
        this.props.dispatch({
            type: 'TakeEvery',
            user: {
                username: 'zs',
                password: '123'
            }
        })
    }

    handleTakeLatest = () => {
        this.props.dispatch({
            // dispatch 里面的这些东西就是完整的一个action
            type: 'TakeLatest',
            user: {
                username: 'zs',
                password: '123'
            }
        })
    }

    handleThrottle = () => {
        this.props.dispatch({
            type: 'Throttle',
            user: {
                username: 'zs',
                password: '123'
            }
        })
    }

    handleTake = () => {
        this.props.dispatch({
            type: 'Take'
        })
    }

    render() {
        return (
            <div>
                <button onClick={this.handleTakeEvery}>TakeEvery</button>
                <button onClick={this.handleTakeLatest}>TakeLatest</button>
                <button onClick={this.handleThrottle}>Throttle</button>
                <button onClick={this.handleTake}>Take</button>
            </div>
        );
    }
}

export default connect()(Home);